home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 May / com_0505_1.iso / opensource / top10 / amc_install.exe / {app} / Scripts / Cineguide_nl_comments.ifs < prev    next >
Encoding:
Text File  |  2004-03-20  |  4.3 KB  |  128 lines

  1. // GETINFO SCRIPTING
  2. // Cineguide (Cinebel) - Dutch (BE) import only summary (and put it in comments field)
  3.  
  4. (***************************************************
  5.  *  Movie importation script for:                  *
  6.  *  CINEGUIDE DUTCH (BE), http://www.cineguide.be  *
  7.  *                                                 *
  8.  *  Script made by Epsilon                         *
  9.  *  New version made by Antoine Potten             *
  10.  *                                                 *
  11.  *  For use with Ant Movie Catalog 3.4.0           *
  12.  *  www.antp.be/software/moviecatalog              *
  13.  *                                                 *
  14.  *  This program is free software; you can         *
  15.  *  redistribute it and/or modify it under the     *
  16.  *  terms of the GNU General Public License as     *
  17.  *  published by the Free Software Foundation;     *
  18.  *  either version 2 of the License, or (at your   *
  19.  *  option) any later version.                     *
  20.  ***************************************************)
  21.  
  22. program CINEGUIDE_NL;
  23. var
  24.   MovieName: string;
  25.  
  26. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  27. var
  28.   i: Integer;
  29. begin
  30.   result := -1;
  31.   if StartAt < 0 then
  32.     StartAt := 0;
  33.   for i := StartAt to List.Count-1 do
  34.     if Pos(Pattern, List.GetString(i)) <> 0 then
  35.     begin
  36.       result := i;
  37.       Break;
  38.     end;
  39. end;
  40.  
  41. procedure AnalyzePage(Address: string);
  42. var
  43.   PageText: string;
  44.   Block: string;
  45.   ResultBlock: Integer;
  46.   BeginPos, EndPos: Integer;
  47.   ValueTitle, ValueAddress: string;
  48. begin
  49.   PageText := GetPage(Address);
  50.   if pos('<a href=/fr/film.asp', PageText) > 0 then
  51.   begin
  52.     SetField(fieldURL, Address);
  53.     AnalyzeMoviePage(PageText)
  54.   end
  55.   else
  56.   begin
  57.     PickTreeClear;
  58.     ResultBlock := Pos('<td class="cadre" height="16">', PageText);
  59.     while ResultBlock > 0 do
  60.     begin
  61.       Delete(PageText, 1, ResultBlock + 35);
  62.       EndPos := Pos('</td>', PageText);
  63.       PickTreeAdd(StringReplace(Copy(PageText, 1, EndPos - 1), #13#10 + '                   ', ''), '');
  64.       BeginPos := EndPos;
  65.       EndPos := Pos('<td height="10"> </td>', PageText);
  66.       Block := Copy(PageText, BeginPos, EndPos - BeginPos);
  67.       Delete(PageText, 1, EndPos);
  68.       BeginPos := Pos('<a href="/nl/film.asp', Block);
  69.       while BeginPos > 0 do
  70.       begin
  71.         Delete(Block, 1, BeginPos - 1);
  72.         EndPos := Pos('</a>', Block);
  73.         ValueTitle := Copy(Block, 1, EndPos - 1);
  74.         HTMLRemoveTags(ValueTitle);
  75.         BeginPos := Pos('"', Block);
  76.         EndPos := Pos('" class', Block);
  77.         ValueAddress := 'http://www.cinebel.be' + Copy(Block, BeginPos + 1, EndPos - BeginPos - 1);
  78.         PickTreeAdd(ValueTitle, ValueAddress);
  79.         EndPos := Pos('</td>', Block);
  80.         Delete(Block, 1, EndPos);
  81.         BeginPos := Pos('<a href="/nl/film.asp', Block);
  82.       end;
  83.       ResultBlock := Pos('<td class="cadre" height="16">', PageText);
  84.     end;
  85.     if PickTreeExec(Address) then
  86.       AnalyzePage(Address);
  87.   end;
  88. end;
  89.  
  90. procedure AnalyzeMoviePage(PageText: string);
  91. var
  92.   Line, Value: string;
  93.   BeginPos, EndPos: Integer;
  94. begin
  95.   BeginPos := Pos('<table border="0" width="95%" cellpadding="0" cellspacing="0">', PageText);
  96.   Delete(PageText, 1, BeginPos);
  97.  
  98.   // Description
  99.   BeginPos := Pos('<hr noshade width="100%" size="1" color="#000000">', PageText);
  100.   Delete(PageText, 1, BeginPos);
  101.   EndPos := Pos('<hr noshade width="100%" size="1" color="#000000">', PageText);
  102.   Line := Copy(PageText, 1, EndPos - 1);
  103.   Delete(PageText, 1, EndPos);
  104.   BeginPos := Pos('>', Line);
  105.   Delete(Line, 1, BeginPos);
  106.   Line := StringReplace(Trim(StringReplace(Line, #13#10, '')), '<br>', #13#10);
  107.   SetField(fieldComments, Line);
  108.   DisplayResults;
  109. end;
  110.  
  111. begin
  112.   if CheckVersion(3,4,0) then
  113.   begin
  114.     MovieName := GetField(fieldOriginalTitle);
  115.     if MovieName = '' then
  116.       MovieName := GetField(fieldTranslatedTitle);
  117.     if Input('Cineguide (Cinebel) Import', 'Enter the title (or the URL) of the movie:', MovieName) then
  118.     begin
  119.       if Pos('cinebel.be', MovieName) > 0 then
  120.         AnalyzePage(MovieName)
  121.       else
  122.         AnalyzePage('http://www.cinebel.be/nl/srch.asp?mot='+UrlEncode(MovieName));
  123.     end;
  124.   end else
  125.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
  126. end.
  127.  
  128.